package Lab06.Extra4;

public interface ICommand {
    void execute();

    Bar getBar();
}

class BuyEggFriedRice implements ICommand {
    Bar bar;
    int num;

    public BuyEggFriedRice(Bar bar, int num) {
        this.bar = bar;
        this.num = num;
    }

    @Override
    public void execute() {
        this.bar.Consume(10*this.num);
        System.out.println("BuyEggFriedRice:"+10*this.num);
    }
    public Bar getBar() {
        return this.bar;
    }
}

class BuyBeer implements ICommand {
    Bar bar;
    int num;

    public BuyBeer(Bar bar, int num) {
        this.bar = bar;
        this.num = num;
    }

    @Override
    public void execute() {
        this.bar.Consume(20*this.num);
        System.out.println("BuyBeer:"+20*this.num);
    }
    public Bar getBar() {
        return this.bar;
    }
}

class BuyVodka implements ICommand {
    Bar bar;
    int num;

    public BuyVodka(Bar bar, int num) {
        this.bar = bar;
        this.num = num;
    }

    @Override
    public void execute() {
        this.bar.Consume(20*this.num);
        System.out.println("BuyVodka:"+20*this.num);
    }
    public Bar getBar() {
        return this.bar;
    }
}

class SpendMoney implements ICommand {
    Engineer engineer;
    double allMoney;
    double money;

    public SpendMoney(Engineer engineer, double allMoney) {
        this.engineer = engineer;
        this.allMoney = allMoney;
    }
    public void SetMoney(double money) {
        this.money = money;
    }
    @Override
    public void execute() {
        System.out.println(this.engineer + " 付款： " + allMoney + " , 找您：" + (this.allMoney - this.money));
    }

    @Override
    public Bar getBar() {
        return null;
    }
    public Engineer getEngineer() {
        return this.engineer;
    }
}
